package com.bins.langchain.ai.rag.test;

import dev.langchain4j.model.ollama.OllamaChatModel;
import dev.langchain4j.service.AiServices;
import dev.langchain4j.service.SystemMessage;

import java.time.Duration;

public class QWEN2Demo {

    interface Assistant {
        @SystemMessage("请用英语回答")
        String chat(String userMessage);
    }
    static OllamaChatModel qwen = OllamaChatModel.builder()
            .baseUrl("http://127.0.0.1:11434")
            .modelName("qwen2")
            .temperature(0d)
            .timeout(Duration.ofSeconds(3000))
            .maxRetries(3)
            .logRequests(true)
            .logResponses(true)
            .build();

    public static void main(String[] args) {
        Assistant assistant = AiServices.create(Assistant.class, qwen);
        String answer = assistant.chat("如何生活更好?");
        System.out.println(answer);
    }
}